package com.safeneeds.linguimana.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.mvc.support.RedirectAttributes;

import com.safeneeds.linguimana.dto.DataStorePort;
import com.safeneeds.linguimana.dto.OndutyDataStorePort;
import com.safeneeds.linguimana.entity.EntityPortGlutOnduty;
import com.safeneeds.linguimana.entity.PortGlutOnduty;
import com.safeneeds.linguimana.entity.PortNews;
import com.safeneeds.linguimana.ser.IBgDutyService;
import com.safeneeds.linguimana.ser.IBgNoticeService;
import com.safeneeds.util.base.BaseAction;
import com.safeneeds.util.base.RetType;
import com.safeneeds.util.other.StringUtil;
import com.safeneeds.util.page.PageInfo;
/**
 * 门户新闻管理
 * @author zqq
 * @date 2017年2月21日
 * desc: 用于处理今日值班模块请求
 */
@Controller
@RequestMapping("bgPortGlutOnduty")
public class BgGlutOndutyAction extends BaseAction {

	
	@Resource(name="bgDutyService")
	private IBgDutyService bgDutyService;
	
	
	@RequestMapping("listOnduty.do")
	public String listOnduty(ModelMap modelMap, PageInfo pageInfo, OndutyDataStorePort ondutyDataStorePort){
		
		if(ondutyDataStorePort != null ){
			//获取分页数据
			pageInfo = bgDutyService.listOndutyPage(pageInfo, ondutyDataStorePort);
			System.out.println(pageInfo);
			System.out.println(ondutyDataStorePort);
		}
		modelMap.put("pageInfo", pageInfo);
		modelMap.put("ondutydataStore", ondutyDataStorePort);
		return getViewsModelPathSys("portmana/bg/glutonduty/ondutyList"); 
	}
	
	/**
	 * 新增/编辑今日值班登录
	 * 
	 * @return
	 */
	@RequestMapping("addOndutyLogin.do")
	public String addOndutyLogin(ModelMap modelMap, PortGlutOnduty portGlutOnduty){
		
		return getViewsModelPathSys("portmana/bg/glutonduty/addOnduty");
	}
	/**
	 * 编辑今日值班登录
	 * @param modelMap
	 * @param portGlutOnduty
	 * @return
	 */
	@RequestMapping("editOndutyLogin.do")
	public String editOndutyLogin(ModelMap modelMap, PortGlutOnduty portGlutOnduty){
		if(!StringUtil.isEmpty(portGlutOnduty.getOndutyId())){
		    EntityPortGlutOnduty EntityOnduty = bgDutyService.getportGlutOnduty(portGlutOnduty.getOndutyId());
			modelMap.put("onduty", EntityOnduty);
			System.out.println(EntityOnduty.toString());
		}
		return getViewsModelPathSys("portmana/bg/glutonduty/editOnduty");
	}
	/**
	 * 添加、更新今日值班
	 * @return
	 */
	@ResponseBody
	@RequestMapping("addOnduty.ido")
	public RetType addOnduty(EntityPortGlutOnduty entityPortGlutOnduty){
		 	
		return bgDutyService.addOrUpdateOnduty(entityPortGlutOnduty);
	}
	
	/**
	 * 
	 * @param entityPortGlutOnduty
	 * @return
	 */
	@ResponseBody
	@RequestMapping("delOnduty.do")
	public RetType delOnduty(String ids){
		 	
		return bgDutyService.deleteOndutyById(ids);
	}
}
